package com.nowcoder.community.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.nowcoder.community.entity.Comment;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CommentMapper extends BaseMapper<Comment> {


    @Select("SELECT * FROM comment " +
            "WHERE status = 0 AND entity_id = #{entityId} AND entity_type = #{entityType} " +
            "ORDER BY create_time ASC " +
            "LIMIT #{offset}, #{limit} ")
    List<Comment> selectPageByEntity(int entityId, int entityType, int offset, int limit);

    @Select("SELECT count(*) FROM comment " +
            "WHERE status = 0 AND entity_id = #{entityId} AND entity_type = #{entityType} ")
    int countByEntity(int entityId, int entityType);
}
